package SSF.App.DDoS;

import SSF.OS.*;

/** Protocol Message used by the DDoS Sessions. ICMP was not in place when we
 * start implementing DDoS package, so we wrote our own application level protocol for it.
 * @author Yougu Yuan
 */
public class DDoSMessage extends ProtocolMessage
{
    public static final int ACK = -3;

    /** "commands", so are "INSTALL", "START_ATTACK", "END_ATTACK"*/
    public static final int HIJACK = -2;
    public static final int INSTALL = -1;
    /** start attack, using falsified source address:port */
    public static final int START_ATTACK = 0;
    public static final int END_ATTACK = 1;
    public static final int UNINSTALL = 2;

    public int action;
    public int targetIP;
    public int targetPort;
    public int attackMethod;
    public int param;             //parameter of this attacking method.
    public int opt;               //used as optinal

    /** size of the message, 5 integers, so 20 bytes.*/ 
    public int bytecount()
    {
	//action + target address + target port + protocol number + parameter
	// + opt
	return 24;
    }

    public DDoSMessage(int command, int target_ip, int target_port,
		       int attack_method, int parameter)
    {
	action = command;
	targetIP = target_ip;
	targetPort = target_port;
	attackMethod = attack_method;
	param = parameter;
	opt = 0;
    }

    public DDoSMessage(DDoSMessage msg)
    {
	action = msg.action;
	targetIP = msg.targetIP;
	targetPort = msg.targetPort;
	attackMethod = msg.attackMethod;
	param = msg.param;
	opt = msg.opt;
    }

    public DDoSMessage(DDoSMessage msg, int opt)
    {
	action = msg.action;
	targetIP = msg.targetIP;
	targetPort = msg.targetPort;
	attackMethod = msg.attackMethod;
	param = msg.param;
	this.opt = opt;
    }
    public DDoSMessage(int command, int target_ip, int target_port,
		       int attack_method, int parameter, int optional)
    {
	action = command;
	targetIP = target_ip;
	targetPort = target_port;
	attackMethod = attack_method;
	param = parameter;
	opt = optional;
    }
}
